function getCookie(c_name)//获取cookie
{
   if (document.cookie.length>0){ 
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1){ 
           c_start=c_start + c_name.length+1;
           c_end=document.cookie.indexOf(";",c_start);
           if (c_end==-1) c_end=document.cookie.length;
           return unescape(document.cookie.substring(c_start,c_end))
        } 
   }
   return ""
}

function setCookie(c_name,value,expiredays)//设置cookie
{
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+";path=/"
}

//删除名称为name的Cookie
function deleteCookie (name) 
{   
    var exp = new Date();
    exp.setTime (exp.getTime() - 1000);
    var cval = '';
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString()+";path=/";
}
 
//清除COOKIE
function ClearCookies()
{
    if(confirm('你确定要清空所有COOKIE吗？'))
    {
        var temp=document.cookie.split(";");
        var ts;
        for (var i=0;;i++)
        {
            if(!temp[i])break;
            ts=temp[i].split("=")[0];
            deleteCookie(ts);
        }
        alert('COOKIE已清除！');
    }
}

